package org.example.erp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.example.erp.domain.Inventory;
import org.example.erp.domain.ProductMaterialManagement;
import org.example.erp.mapper.MaterialMapper;
import org.example.erp.service.InventoryService;
import org.example.erp.mapper.InventoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
* @author 86180
* @description 针对表【inventory(库存管理表)】的数据库操作Service实现
* @createDate 2024-11-28 15:28:32
*/
@Service
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory>
    implements InventoryService{

    @Autowired
    private MaterialMapper materialMapper;

    public IPage<Inventory> find(
            Integer currentPage,
            Integer pageSize,
            String materialProductCode,
            String materialProductName,
            String inboundBatchNumber,
            String warehouseName,
            String supplierCode,
            String supplierName,
            String validityPeriodOfInventory, Integer materialId) {
        Page<Inventory> page = new Page<>(currentPage, pageSize);
        List<Integer> list = new ArrayList<>();
        if (materialId != null) {
            list = materialMapper.findMaterialIds(materialId);
            list.add(materialId);
            return baseMapper.findinventory(page,materialProductCode,materialProductName,inboundBatchNumber,warehouseName,supplierCode,supplierName,validityPeriodOfInventory, list);
        }
        return baseMapper.findinventory(page,materialProductCode,materialProductName,inboundBatchNumber,warehouseName,supplierCode,supplierName,validityPeriodOfInventory, list);
    }

    public List<Inventory> findInventoryById(String id){
        return baseMapper.findInventoryById(id);
    }
}




